import { Flex, Typography } from "antd"
import { ColumnGroupType, ColumnType } from "antd/es/table"

import { SaveButton } from "@/components/common/saveButton"
import { handleNumber, handleNumberColor } from "@/utils/util"

export const agentIncomeAmountOperationRecordListsetupColumns = (
	newFormat: (p: { id: string } | string) => string,
	_getFromDic: (arg: string, strictlyLabel?: boolean) => any
): Record<string, ColumnGroupType<any> | ColumnType<any>> => ({
	agentIncomeAmountOperationRecord_reportDate: {
		key: "reportDate",
		dataIndex: "reportDate",
		title: newFormat("report.rebate_cycle"),
		width: 120,
		align: "center"
	},
	agentIncomeAmountOperationRecord_proxyName: {
		key: "proxyName",
		dataIndex: "proxyName",
		title: newFormat("funds.proxy_name"),
		align: "center",
		width: 120,
		render: (_, record: any) => (
			<Flex align="center" gap={5} justify="center">
				<Typography>{record.proxyName}</Typography>
				<SaveButton value={record.proxyName} />
			</Flex>
		)
	},
	agentIncomeAmountOperationRecord_businessModel: {
		key: "businessModel",
		dataIndex: "businessModel",
		title: newFormat("label.member.business_model"),
		align: "center",
		width: 120,
		render: (_text: any, record: any) =>
			(() => {
				let contentToRender
				switch (record.businessModel) {
					case 0:
						contentToRender = <p>{newFormat("label.business_model_both")}</p>
						break
					case 1:
						contentToRender = <p>{newFormat("label.business_model_cash")}</p>
						break
					case 2:
						contentToRender = <p>{newFormat("label.business_model_credit")}</p>
						break
					default:
						contentToRender = <p>-</p>
				}
				return contentToRender
			})()
	},
	agentIncomeAmountOperationRecord_merchantName: {
		key: "merchantName",
		dataIndex: "merchantName",
		title: newFormat("agent.belong_merchant"),
		align: "center"
	},
	agentIncomeAmountOperationRecord_adjustAmount: {
		key: "adjustAmount",
		dataIndex: "adjustAmount",
		title: newFormat("funds.income_amount"),
		align: "center",
		render: (text: string, record: any) => {
			return (
				<span style={{ color: handleNumberColor(record.adjustAmount) }}>{handleNumber("USDT", record.adjustAmount, 2)} </span>
			)
		}
	},
	agentIncomeAmountOperationRecord_operatorName: {
		key: "operatorName",
		dataIndex: "operatorName",
		title: newFormat("common.updateBy"),
		align: "center"
	},
	agentIncomeAmountOperationRecord_operatorDate: {
		key: "operatorDate",
		dataIndex: "operatorDate",
		title: newFormat("common.updateAt"),
		align: "center"
	},
	agentIncomeAmountOperationRecord_remark: {
		key: "remark",
		dataIndex: "remark",
		title: newFormat("common.remark"),
		align: "center"
	}
})
